import request from '@/utils/http'
import { BaseResponse } from '@/types/api'

//查询所有题库分页接口
export class getupdateList {
  static getupdateId(params: object) {
    return request.get<BaseResponse>({
      url: `ds-question/page`,
      params
    })
  }
}

//新增题库接口
export class addupdateList {
  static addupdateId(params: object) {
    return request.post<BaseResponse>({
      url: `ds-question`,
      params
    })
  }
}

//查询车型下拉接口
export class getcarmodellist {
  static getcarmodelId(params: object) {
    return request.get<BaseResponse>({
      url: `ds-car-model/options`,
      params
    })
  }
}

//获取分组树形结构
export class getdsquestiongroup {
  static getdsquestiongroupId(params: object) {
    return request.get<BaseResponse>({
      url: `ds-question-group/tree`,
      params
    })
  }
}

//获取科目类目下拉接口
export class getquestioncategory {
  static getquestioncategoryId(params: object) {
    return request.get<BaseResponse>({
      url: `ds-question-category/options`,
      params
    })
  }
}

//删除题库接口
export class delquestionlist {
  static delquestionlistId(id: string) {
    return request.del<BaseResponse>({
      url: `ds-question/${id}`
    })
  }
}

//修改题库接口
export class putquestioncategory {
  static putquestioncategoryId(id: string, params: object) {
    return request.put<BaseResponse>({
      url: `ds-question/${id}`,
      params
    })
  }
}

export function getCanSelectQuestion(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-question-group/pageQuestion',
    params
  })
}

export function downQuestionExcel(data: object) {
  return request.post<Promise<Blob>>({
    url: '/ds-question/export',
    responseType: 'blob',
    data
  })
}

export function asyncQuestion(params: object) {
  return request.get<BaseResponse>({
    url: '/ds-question/syncQuestion',
    params,
    timeout: 180000
  })
}

export function relationQuestion(data: object) {
  return request.post<BaseResponse>({
    url: '/ds-question/relationGroup',
    data
  })
}

export function delRelationQuestion(data: object) {
  return request.del<BaseResponse>({
    url: '/ds-question/delRelationGroup',
    data
  })
}

// 下载题库模板
export function exportQuestion() {
  return request.post<Promise<Blob>>({
    url: 'ds-question-group/export',
    responseType: 'blob'
  })
}

// 基础题库统计数据
export function getStatData(params: object) {
  return request.get<BaseResponse>({
    url: 'ds-question/statData',
    params
  })
}
// 题库操作记录
export function operationRecords(params: object) {
  return request.get<BaseResponse>({
    url: 'question/operation/getPage',
    params
  })
}

export function getStatDataToType(params: object) {
  return request.get<BaseResponse>({
    url: 'ds-question/statDataToType',
    params
  })
}

export function addVideoData(data: object) {
  return request.post<BaseResponse>({
    url: 'ds-question/saveQuestionToVideo',
    data
  })
}

export function getExamConfig(params: object) {
  return request.get<BaseResponse>({
    url: 'ds-question-group/getExamConfig',
    params
  })
}

export function setExamConfig(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `ds-question-group/examConfig/${id}`,
    data
  })
}

export function syncGroup(data: object) {
  return request.post<BaseResponse>({
    url: `ds-question-group/sync`,
    data
  })
}

export function getIconSkillExportTemplate(data: object) {
  return request.post<Promise<Blob>>({
    url: 'ds-question-group/exportIcon',
    responseType: 'blob',
    data
  })
}

// 获取当前分组下所有文章分页列表
export function getArticleList(data: object) {
  return request.get<BaseResponse>({
    url: 'StoreArticle/getArticlePage',
    params: data
  })
}
// 新增文章
export function addArticleList(data: object) {
  return request.post<BaseResponse>({
    url: 'StoreArticle/addArticle',
    data
  })
}
// 编辑文章
export function editArticleList(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `StoreArticle/updateArticle/${id}`,
    data
  })
}
// 删除文章
export function delArticleList(ids: string) {
  return request.del<BaseResponse>({
    url: `StoreArticle/delArticle/${ids}`
  })
}
//数据概况 获取过去x天的浏览量统计数据
export function getBrowseStaticInfo(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/DataOverview/getToDay`,
    params: data
  })
}
// 获取分页考试数据
export function getExamRecordInfo(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/StudyAnalytics/page`,
    params: data
  })
}
// 学习分享获取基础统计数据
export function getLearningAnalysisStatic() {
  return request.get<BaseResponse>({
    url: `analytics/StudyAnalytics/getBasic`
  })
}
//学习分析 获取过去x天的考试人数统计数据
export function getExamPeopleStatic(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/StudyAnalytics/getToDay`,
    params: data
  })
}
//学习分析 获取过去x天的考试次数统计数据
export function getExamNumStatic(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/StudyAnalytics/getToNum`,
    params: data
  })
}
//用户分析 获取基础统计数据 - 统计的t-1的数据
export function getUserBasis() {
  return request.get<BaseResponse>({
    url: `analytics/UserAnalytics/getBasic`
  })
}
//用户分析 获取过去x天的用户分析统计数据 - 统计的t-days -> t-1 的数据
export function getUserStatic(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/UserAnalytics/getToDay`,
    params: data
  })
}
//用户分析 用户概况的数据
export function getUserProfile(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/UserAnalytics/page`,
    params: data
  })
}

//交易分析 获取基础统计数据 - 统计的t-1的数据
export function getTradeAnalytics() {
  return request.get<BaseResponse>({
    url: `analytics/TradeAnalytics/getBasic`
  })
}
//交易分析 获取过去x天的交易分析统计数据 - 统计的t-days -> t-1 的数据
export function getTradeStatic(data: object) {
  return request.get<BaseResponse>({
    url: `analytics/TradeAnalytics/getToDay`,
    params: data
  })
}
//数据分析 获取过去x天的交易分析统计数据 - 统计的t-days -> t-1 的数据
export function getBasicStatic() {
  return request.get<BaseResponse>({
    url: `analytics/TrafficAnalytics/getBasic`
  })
}
//查询符合条件的分组下拉选
export function getGroupOptions(data: object) {
  return request.post<BaseResponse>({
    url: `ds-question-group/getGroupOptions`,
    data
  })
}
//将指定题目id集合复制/移动至选定分组
export function copyOrMoveGroup(data: object) {
  return request.post<BaseResponse>({
    url: `ds-question-group/copyOrMoveQuestion`,
    data
  })
}
//同步视频课程
export function getSyncVideo() {
  return request.get<BaseResponse>({
    url: `ds-question-group/syncVideo`
  })
}
// 同步图文课程
export function syncArticleGroupList() {
  return request.get<BaseResponse>({
    url: `StoreArticle/sync`
  })
}

